package com.mayundev.pa.controller;

import com.mayundev.pa.model.FileNode;
import com.mayundev.pa.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/files")
@CrossOrigin
public class FileController {
    
    @Autowired
    private FileService fileService;

    @GetMapping("/tree")
    public List<FileNode> getFileTree() {
        return fileService.getFileTree();
    }

    @GetMapping("/content")
    public String getFileContent(@RequestParam String path) {
        return fileService.getFileContent(path);
    }
}
